﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Script_Text_Editor_WPF_Edition"
        xmlns:p="clr-namespace:Script_Text_Editor_WPF_Edition.Properties"
        x:Class="Script_Text_Editor_WPF_Edition.MainWindow"
        Height="{Binding Source={x:Static p:Settings.Default},Path=WindowHeight}"
        Width="{Binding Source={x:Static p:Settings.Default},Path=WindowWidth}"
        x:Name="formMain" FontFamily="SimSun"
        Loaded="formMain_Loaded" Closing="formMain_Closing"
        Icon="/Script%20Text%20Editor%20WPF%20Edition;component/icon.ico"
        >

    <DockPanel LastChildFill="True" x:Name="dockPanelMain">
        <DockPanel.Resources>
            <!--列表框背景-->
            <Style x:Key="listViewStyle">
                <Style.Resources>
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{Binding Source={x:Static p:Settings.Default},Path=listViewSelection}" />
                </Style.Resources>
            </Style>
            <!--列表框背景-->
            <!--触发器-->
            <Style x:Key="opacityStyle">
                <Style.Triggers>
                    <EventTrigger RoutedEvent="Mouse.MouseEnter">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="Opacity" To="1.0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Mouse.MouseLeave">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="Opacity" To="0.3" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Style.Triggers>
            </Style>
            <!--触发器-->
            <!--查找工具栏触发器-->
            <Style x:Key="searchPanelStyle" TargetType="StackPanel">
                <Style.Triggers>
                    <Trigger Property="Visibility" Value="Visible">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" />
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                    </Trigger>
                    <EventTrigger RoutedEvent="Mouse.MouseEnter">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="Opacity" To="1.0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Mouse.MouseLeave">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="Opacity" To="0.3" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Style.Triggers>
            </Style>
            <!--查找工具栏触发器-->
        </DockPanel.Resources>

        <DockPanel.Background>
            <ImageBrush ImageSource="{Binding Source={x:Static p:Settings.Default},Path=BackgroundImage}" Stretch="UniformToFill" />
        </DockPanel.Background>

        <Menu DockPanel.Dock="Top" Background="#DDFFFFFF" Opacity="0.3" FontFamily="SimSun" x:Name="menuMain" Style="{Binding Source={StaticResource opacityStyle}}">
            <MenuItem Header="文件">
                <MenuItem Header="开始新翻译" x:Name="menuFileNew" Click="menuFileNew_Click" />
                <MenuItem Header="继续翻译进程" x:Name="menuFileContinue" Click="menuFileContinue_Click" />
                <Separator />
                <MenuItem Header="保存翻译进度" x:Name="menuFileSave" Click="menuFileSave_Click"/>
                <MenuItem Header="完成翻译" x:Name="menuFileFinish" Click="menuFileFinish_Click" />
                <Separator />
                <MenuItem Header="退出" x:Name="menuExit" Click="menuExit_Click" />
            </MenuItem>
            <MenuItem Header="编辑">
                <MenuItem Header="批量导出" x:Name="nemuEditBatchOutput" />
                <MenuItem Header="批量导入" x:Name="nemuEditBatchInput" />
            </MenuItem>
            <MenuItem Header="视图">
                <MenuItem Header="环境设定" x:Name="menuViewSettings" Click="menuViewSettings_Click" />
            </MenuItem>
        </Menu>

        <StatusBar Background="#DDFFFFFF" Opacity="0.3" FontFamily="SimSun" DockPanel.Dock="Bottom" Style="{Binding Source={StaticResource opacityStyle}}">
            <StatusBar.Resources>
                <local:ConverterIndex2DecNumber x:Key="converterIndex2DecNumber"/>
            </StatusBar.Resources>
            <TextBlock Text="当前行号："/>
            <TextBlock Text="{Binding SelectedIndex, Converter={StaticResource converterIndex2DecNumber}, ElementName=listViewMain}"/>
            <TextBlock Text="总行数："/>
            <TextBlock Text="{Binding Items.Count, ElementName=listViewMain}"/>
            <TextBlock Text="就绪。" Name="textBlockInfo" />
        </StatusBar>

        <StackPanel Name="searchPanel" Background="#DDFFFFFF" DockPanel.Dock="Bottom" Style="{StaticResource searchPanelStyle}" Visibility="Collapsed">
            <DockPanel>
                <Button Content="下一个" DockPanel.Dock="Right" Name="buttonSearchPanelNext" Click="buttonSearchPanelNext_Click" />
                <Button Content="上一个" DockPanel.Dock="Right" Name="buttonSearchPanelPrev" Click="buttonSearchPanelPrev_Click" />
                <ComboBox DockPanel.Dock="Right" SelectedIndex="0" Name="comboBoxSearchPanelOption">
                    <ComboBoxItem Content="两者" />
                    <ComboBoxItem Content="原文" />
                    <ComboBoxItem Content="译文" />
                </ComboBox>
                <TextBlock Text="查找文字：" DockPanel.Dock="Left" VerticalAlignment="Center" />
                <TextBox Background="Transparent" Name="textBoxSearchPanelOrg" />
            </DockPanel>
            <DockPanel>
                <Button Content="全部替换" DockPanel.Dock="Right" Name="buttonSearchPanelReplaceAll" Click="buttonSearchPanelReplaceAll_Click" />
                <Button Content="替换一次" DockPanel.Dock="Right" Name="buttonSearchPanelReplace" Click="buttonSearchPanelReplace_Click" />
                <TextBlock Text="替换为：" DockPanel.Dock="Left" VerticalAlignment="Center" />
                <TextBox Background="Transparent" Name="textBoxSearchPanelNew" />
            </DockPanel>
        </StackPanel>

        <ToolBarPanel Opacity="0.3" Background="#DDFFFFFF" DockPanel.Dock="Left" Style="{Binding Source={StaticResource opacityStyle}}">
            <Button Click="buttonSearchPanel_Click" Name="buttonSearchPanel">
                <Image Height="16" Width="16" Source="/Script%20Text%20Editor%20WPF%20Edition;component/Images/FindDialog.png" />
            </Button>
            <TextBlock Height="8"/>
            <Button Name="buttonMark" Click="buttonMark_Click">
                <Image Height="16" Width="16" Source="/Script%20Text%20Editor%20WPF%20Edition;component/Images/ReviewInkCommentNew.png"/>
            </Button>
            <Button Name="buttonMarkPrev" Click="buttonMarkPrev_Click">
                <Image Height="16" Width="16" Source="/Script%20Text%20Editor%20WPF%20Edition;component/Images/ReviewPreviousComment.png"/>
            </Button>
            <Button Name="buttonMarkNext" Click="buttonMarkNext_Click">
                <Image Height="16" Width="16" Source="/Script%20Text%20Editor%20WPF%20Edition;component/Images/ReviewNextComment.png"/>
            </Button>
            <Button Name="buttonMarkErase" Click="buttonMarkErase_Click">
                <Image Height="16" Width="16" Source="/Script%20Text%20Editor%20WPF%20Edition;component/Images/ReviewDeleteComment.png" />
            </Button>
            <Button Name="buttonMarkEraseAll" Click="buttonMarkEraseAll_Click">
                <Image Height="16" Width="16" Source="/Script%20Text%20Editor%20WPF%20Edition;component/Images/ReviewDeleteAllMarkupOnSlide.png" />
            </Button>
        </ToolBarPanel>

        <ListView Background="Transparent" x:Name="listViewMain" BorderThickness="0" FontSize="16"
                  Focusable="False"
                  PreviewKeyDown="listViewMain_PreviewKeyDown" SelectionChanged="listViewMain_SelectionChanged">
            <ListView.Resources>
                <local:ConverterWindowWidth2TextBoxWidth x:Key="converterWindowWidth2TextBoxWidth"/>
                <local:ConverterBool2Brush x:Key="converterBool2Brush"/>
                <local:ConverterColor2Brush x:Key="converterColor2Brush"/>
            </ListView.Resources>
            <ListView.Style>
                <StaticResource ResourceKey="listViewStyle"/>
            </ListView.Style>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical" Background="{Binding Marked,Converter={StaticResource converterBool2Brush}}">
                        <TextBox x:Name="textBoxOrg"
                                 FontFamily="{Binding Source={x:Static p:Settings.Default},Path=textBoxOrgFontName}"
                                 FontSize="{Binding Source={x:Static p:Settings.Default},Path=textBoxOrgFontSize}"
                                 FontWeight="{Binding Source={x:Static p:Settings.Default},Path=textBoxOrgFontWeight}"
                                 Width="{Binding ActualWidth, Converter={StaticResource converterWindowWidth2TextBoxWidth}, ElementName=listViewMain}"
                                 Background="{Binding Source={x:Static p:Settings.Default},Path=textBoxOrgBack,Converter={StaticResource converterColor2Brush}}"
                                 BorderBrush="#00000000"
                                 TextWrapping="Wrap"
                                 Text="{Binding OrgText}"
                                 IsReadOnly="True"
                                 AutoWordSelection="True"
                                 />
                        <TextBox x:Name="textBoxNew"
                                 FontFamily="{Binding Source={x:Static p:Settings.Default},Path=textBoxNewFontName}"
                                 FontSize="{Binding Source={x:Static p:Settings.Default},Path=textBoxNewFontSize}"
                                 FontWeight="{Binding Source={x:Static p:Settings.Default},Path=textBoxNewFontWeight}"
                                 Width="{Binding ActualWidth, Converter={StaticResource converterWindowWidth2TextBoxWidth}, ElementName=listViewMain}"
                                 Background="{Binding Source={x:Static p:Settings.Default},Path=textBoxNewBack,Converter={StaticResource converterColor2Brush}}"
                                 BorderBrush="#00000000"
                                 TextWrapping="Wrap"
                                 Text="{Binding NewText}"
                                 AcceptsReturn="True"
                                 AutoWordSelection="True"
                                 GotFocus="textBoxNew_GotFocus"
                                 />
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </DockPanel>
</Window>